package com.ecable.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Vector;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ecable.bean.ProfileTO;
import com.ecable.daoImpl.ConnectionDaoImpl;
import com.ecable.util.UtilConstants;

public class ViewOperatorBillStatusAction extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		String path = "";
		String state = request.getParameter("state");
		String district = request.getParameter("district");
		String city = request.getParameter("city");
		System.out.println(state);
		System.out.println(district);
		System.out.println(city);
		Vector<ProfileTO> vpf = null;

		try {
			vpf = new ConnectionDaoImpl().getOperatorBillsStatus(state,
					district, city);

			if (!vpf.isEmpty()) {
				request.setAttribute("status", UtilConstants._Bills_INFO);
				request.setAttribute("vpf", vpf);
				path = UtilConstants._VIEW__OPERATOR_Bills;
			} else {

				request.setAttribute("status", UtilConstants._operator__Bills);
				path = UtilConstants._view_operator__Bills;

			}

		} catch (Exception e) {

			request.setAttribute("status", UtilConstants._INVALIED_ENTRY);
			path = UtilConstants._view_operator__Bills;

		}
		RequestDispatcher rd = request.getRequestDispatcher(path);

		rd.forward(request, response);

	}

}
